﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TheVerge.Base.Models;

namespace TheVerge.Base.Platform
{
    public interface IAudioPlayer
    {
        AudioPlayState CurrentState { get; }

        bool IsActiveTrack(VMPodcast podcast);
        bool IsPlaying(VMPodcast podcast);
        bool IsPlayingPodcast();

        void FastForward();
        void Pause();
        void Play(VMPodcast podcast);
        void Rewind();
        bool Seek(TimeSpan ts);

        TimeSpan Duration { get; }
        TimeSpan Position { get; }

        event EventHandler<AudioPlayStateChangedEventArgs> PlayStateChanged;    
    }
    
    public class AudioPlayStateChangedEventArgs : EventArgs
    {
        public AudioPlayState CurrentState { get; set; }
    }

    // Summary:
    //     Indicates the possible states that the player can be in, with respect to
    //     the current application's background audio.
    public enum AudioPlayState
    {
        // Summary:
        //     The current Microsoft.Phone.BackgroundAudio.PlayState is indeterminate. For
        //     example, a new Microsoft.Phone.BackgroundAudio.AudioTrack has been set, but
        //     playback has not been initiated.
        Unknown = 0,
        //
        // Summary:
        //     No playback is occurring in this application.
        Stopped = 1,
        //
        // Summary:
        //     Playback for this application is paused.
        Paused = 2,
        //
        // Summary:
        //     This application is currently playing a track.
        Playing = 3,
        //
        // Summary:
        //     The current track has started buffering.
        BufferingStarted = 4,
        //
        // Summary:
        //     The current track has stopped buffering.
        BufferingStopped = 5,
        //
        // Summary:
        //     The current track is ready for playback.
        TrackReady = 6,
        //
        // Summary:
        //     The last track has ended and this application is currently changing tracks.
        TrackEnded = 7,
        //
        // Summary:
        //     The current track is rewinding.
        Rewinding = 8,
        //
        // Summary:
        //     The current track is fast-forwarding.
        FastForwarding = 9,
        //
        // Summary:
        //     The application has shutdown.
        Shutdown = 10,
        //
        // Summary:
        //     An error occurred.
        Error = 11,
    }
}
